﻿Chenxin.UI.ArchiveDetailInfo = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: '/service/logic/ShowListArchive.ashx',
    loadinfo: function() {
        var _this = this;
        Chenxin.ajax({
            type: "get",
            dataType: "text",
            paramType: 'json',
            async:false,
            url: this.actionUrl,
            data: { op: 'getmodel', modelid: this.currentId },
            onSuccess: function(data, msg) {
                if (data) {
                    _this.currentArchiveInfo = data;
                }
            }
        });
    },
    initEvent: function() {
        var _this = this;
	
        if (_this.currentId != $("#ctl00_main_hidRecordId").val()) {
            _this.currentId = $("#ctl00_main_hidRecordId").val();
            _this.loadinfo();
        }
        
        //修改报备
        $('#aEditArchive').click(function(){
            _this.editArchive();
        });

        //日常回复
        $('#aDailyReply').click(function(){
            _this.showDailyToReply();
        });

        //法务回复
        $('#aLawReply').click(function(){
            _this.showLawToReply();
        });
        
        //办证回复
        $('#aApplyDocReply').click(function(){
            _this.showApplyDocToReply();
        });
        
        //贷款回复
        $('#aLoanReply').click(function(){
            _this.showLoanToReply();
        });
        
        //上传附件
        $('#aUploadAttachment').click(function(){
            _this.uploadAttachment();
        });
        
    },
    editArchive: function(){
        var _this = this;
        if (!_this.currentId) {
            alert('请先选择一条报备记录！');
            return;
        }
        window.location.href = "/page/Business_Record/ContractArchive.aspx?RecordId="+_this.currentId+"";
        
    },
    showDailyToReply: function(){
        var _this = this;
        if (!this.DailyToReplyForm) {
            this.DailyToReplyForm = new Chenxin.UI.DailyToReplyForm({
                scrop: _this,
                alwaysCheckPermit: true,
                saveSucc:function(){
                    window.location.reload();
			    }
            });
        }
        this.DailyToReplyForm.op = "savedailytoreply";
        if(this.DailyToReplyForm.show(this.DailyToReplyForm.op, { currentId: _this.currentId })) {
            this.DailyToReplyForm.reset();
            var _data = this.currentArchiveInfo;
            this.DailyToReplyForm.fitData(_data);
            this.DailyToReplyForm.setTitle('日常回复');
        }
    },
    showLoanToReply: function(){
        var _this = this;
        if (!this.LoanToReplyForm) {
            this.LoanToReplyForm = new Chenxin.UI.LoanToReplyForm({
                scrop: _this,
                alwaysCheckPermit: true,
                saveSucc:function(){
                    window.location.reload();
			    }
            });
        }
        this.LoanToReplyForm.op = "saveloantoreply";
        if(this.LoanToReplyForm.show(this.LoanToReplyForm.op, { currentId: _this.currentId })) {
            this.LoanToReplyForm.reset();
            var _data = this.currentArchiveInfo;
            this.LoanToReplyForm.fitData(_data);
            this.LoanToReplyForm.setTitle('贷款回复');
        }  
    },
    showLawToReply: function(){
        var _this = this;
        if (!this.LawToReplyForm) {
            this.LawToReplyForm = new Chenxin.UI.LawToReplyForm({
                scrop: _this,
                alwaysCheckPermit: true,
                beforeSave:function(){
                    _this.op="savelawtoreply";
                },
                saveSucc:function(){
                    window.location.reload();
			    }
            });
        }
        this.LawToReplyForm.op = "savelawtoreply";
        if(this.LawToReplyForm.show(this.LawToReplyForm.op, { currentId: _this.currentId })) {
            this.LawToReplyForm.reset();
            var _data = this.currentArchiveInfo;
            this.LawToReplyForm.fitData(_data);
        }
        this.LawToReplyForm.setTitle('法务回复');
        $("#tr_law").show();
        $("#tr_applydoc").hide();
    },
    showApplyDocToReply: function(){
        var _this = this;
        if (!_this.currentId) {
            alert('请先选择一条报备记录！');
            return;
        }
        if (!this.LawToReplyForm) {
            this.LawToReplyForm = new Chenxin.UI.LawToReplyForm({
                scrop: _this,
                alwaysCheckPermit: true,
                beforeSave:function(){
                    _this.op="saveapplydoctoreply";
                },
                saveSucc:function(){
                    window.location.reload();
			    }
            });
        }
        this.LawToReplyForm.op = "saveapplydoctoreply";
        if(this.LawToReplyForm.show(this.LawToReplyForm.op, { currentId: _this.currentId })) {
            this.LawToReplyForm.reset();
            var _data = this.currentArchiveInfo;
            this.LawToReplyForm.fitData(_data);
        }
        this.LawToReplyForm.setTitle('办证回复');
        $("#tr_law").hide();
        $("#tr_applydoc").show();
    },
    uploadAttachment: function(){
        var _this = this;
        if (!_this.currentId) {
            alert('请先选择一条报备记录！');
            return;
        }
        if (!this.UploadAttachmentForm) {
            this.UploadAttachmentForm = new Chenxin.UI.UploadAttachmentForm({
                scrop: _this,
                alwaysCheckPermit: true,
                saveSucc:function(){
                    window.location.reload();
			    }
            });
        }
        this.UploadAttachmentForm.op = "uploadattachment";
        if(this.UploadAttachmentForm.show(this.UploadAttachmentForm.op, { currentId: _this.currentId })) {
            this.UploadAttachmentForm.reset();
            var _data = this.currentArchiveInfo;
            this.UploadAttachmentForm.fitData(_data);
            this.UploadAttachmentForm.setTitle('上传附件');
        } 
    },
    initComponent: function() {
        Chenxin.UI.ArchiveDetailInfo.superclass.initComponent.call(this);
    }
});

getcity = true; //设置需要获取城市下拉框数据

$(document).ready(function(){
    this.ArchiveDetailInfo=new Chenxin.UI.ArchiveDetailInfo();
});